<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateCustomPaymentsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('custom_payments', function (Blueprint $table) {
            $table->id();
            $table->string('name')->default('')->comment('自定义支付名称');
            $table->unsignedTinyInteger('reckonType')->default(1)->comment('计入类型 1 计入实收 2 计入优惠');
            $table->unsignedTinyInteger('isInvoice')->default(0)->comment('是否开发票 0 否 1 是');
            $table->unsignedTinyInteger('type')->default(2)->comment('类型 1 默认 2 自定义');
            $table->unsignedTinyInteger('status')->default(0)->comment('状态 0 正常 1 停用');
            //数据表通用字段
            $table->unsignedTinyInteger('isDeleted')->default(0)->comment("是否删除 0：未删除 1：已删除");
            $table->integer('createdAt')->default(0)->comment('创建时间');
            $table->integer('createdByUid')->default(0)->comment('创建人');
            $table->integer('updatedAt')->default(0)->comment('修改时间');
            $table->integer('updatedByUid')->default(0)->comment('修改人');

            $table->index('name', 'idx_name');
            $table->comment = "自定义支付配置表";
        });

        $prefix = config('other.DB_PREFIX', '');
        \Illuminate\Support\Facades\DB::statement("ALTER TABLE `{$prefix}custom_payments` AUTO_INCREMENT=102");//从102开始自增
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('custom_payments');
    }
}
